﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HA.Data.DisplayOptions2
{

    [Serializable ]
    public class DOContourLineProperty : ContourEventProperty, IObjectDataHelper, ICloneable 
    {

        //注意 ：修改字段后 需要修改运算符重载


        public DOContourLineProperty()
        {

            //this._contourlines = new ContourLinesConfigure();


            this._lineScalarBar = new ContourLineScalarBar();
            this._lineTagging = new ContourLineTagging();
        
        }


        ////等值线LIne
        //ContourLinesConfigure _contourlines;

        //public ContourLinesConfigure Contourlines
        //{
        //    get { return _contourlines; }
        //    //set { _contourlines = value; }
        //}



        //标注
        ContourLineTagging _lineTagging;
        /// <summary>
        /// 标注
        /// </summary>
        public ContourLineTagging LineTagging
        {
            get { return _lineTagging; }
            //set { _lineTagging = value; }
        }



        //图例

        ContourLineScalarBar _lineScalarBar;
        /// <summary>
        /// 图例
        /// </summary>
        public ContourLineScalarBar LineScalarBar
        {
            get { return _lineScalarBar; }
            //set { _lineScalarBar = value; }
        }




        #region 运算符重载


        public static bool operator ==(DOContourLineProperty sp1, DOContourLineProperty sp2)
        {
            if ((object)sp1 ==null &&(object)sp2 ==null )
            {
                return true;
            }

            if (((object)sp1 == null && (object)sp2 != null) || ((object)sp1 != null && (object)sp2 == null))
            {
                return false;
            }


            if (sp1 != null && sp2 != null)
            {

                //等值线属性配置参数   的  比较需要重写

                //if (sp2 ._contourlines !=sp1 ._contourlines )
                //{
                //    return false;
                //}
                if (sp2 ._lineScalarBar !=sp1 ._lineScalarBar )
                {
                    return false;   
                }
                if (sp2 ._lineTagging !=sp1 ._lineTagging )
                {
                    return false;
                }
            }



            return true;
        }

        public static bool operator !=(DOContourLineProperty sp1, DOContourLineProperty sp2)
        {
            return (!(sp1 == sp2));

        }


        #endregion




        public override void SetIsNeedUpdateDataToFalse()
        {
            base.SetIsNeedUpdateDataToFalse();


            this.isNeedUpdateData = false;
            //if (this._contourlines !=null )
            //{
            //    this._contourlines.SetIsNeedUpdateDataToFalse();
            //}
            if (this._lineScalarBar !=null )
            {
                this._lineScalarBar.SetIsNeedUpdateDataToFalse();
            }
            if (this._lineTagging !=null )
            {
                this._lineTagging.SetIsNeedUpdateDataToFalse();
            }


        }

        #region IObjectDataHelper 成员

        public void ResetDataAndTriggerEvent(object obj)
        {


            if (obj == null)
            {
                return;

            }
            DOContourLineProperty doContour = (DOContourLineProperty)obj;

            //运算符重载   其根本还是遍历类中的所有字段进行了比较  
            if (doContour.IsDataChanged() == false)
            {
                return;
            }


            if (this._lineScalarBar !=null )
            {
                this._lineScalarBar.ResetDataAndTriggerEvent(doContour._lineScalarBar );
            }
            if (this._lineTagging !=null )
            {
                this._lineTagging.ResetDataAndTriggerEvent(doContour ._lineTagging );
            }







            //throw new NotImplementedException();
        }

        public bool IsDataChanged()
        {

            if (this.isNeedUpdateData == true)
            {
                return true;
            }
            else
            {
                if (( this._lineScalarBar == null && this._lineTagging == null))
                {
                    return false;
                }
                else
                {
                    if ((this._lineScalarBar !=null &&this._lineScalarBar .IsDataChanged ()==true )||(this._lineTagging !=null &&this._lineTagging .IsDataChanged ()==true ))
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }

            //return false;
            //throw new NotImplementedException();
        }

        #endregion

        #region ICloneable 成员

        public object Clone()
        {
            DOContourLineProperty obj = (DOContourLineProperty)this.MemberwiseClone();

            obj._lineScalarBar = (ContourLineScalarBar)this._lineScalarBar.Clone();

            obj._lineTagging = (ContourLineTagging)this._lineTagging.Clone();


            return obj;





            //throw new NotImplementedException();
        }

        #endregion
    }

}
